package Dao;

import Enumeracion.EstadoDetallePrestamo;
import Modelo.Detalleprestamo;
import Modelo.Prestamo;
import java.util.List;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;

@Stateless
public class DetalleprestamoDao extends AbstractDao<Detalleprestamo> implements DetalleprestamoDaoLocal {
    @PersistenceContext(unitName = "BibliotecaAmalia-ejbPU")
    private EntityManager em;

    @Override
    protected EntityManager getEntityManager() {
        return em;
    }

    public DetalleprestamoDao() {
        super(Detalleprestamo.class);
    }
    
    @Override
    public List<Detalleprestamo> findLends(Prestamo lend) {
        Query q=em.createNamedQuery("Detalleprestamo.findLends");
        q.setParameter("estado",EstadoDetallePrestamo.LEND.ordinal());
        q.setParameter("idPrestamo", lend.getId());
        return q.getResultList();
    }
}
